import http from '@/utils/http'

const BASE_URL = '/asset/service/records'

export interface ServiceRecordsResp {
  id: string
  name: string
  description: string
  status: string
  producerId: string
  price: string
  purchaseDate: string
  expireDate: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
  disabled: boolean
}
export interface ServiceRecordsDetailResp {
  id: string
  code: string
  name: string
  description: string
  status: string
  producerId: string
  producerName: string
  price: string
  purchaseDate: string
  expireDate: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface ServiceRecordsQuery {
  name: string | undefined
  producerId: string | undefined
  purchaseDate: string | undefined
  expireDate: string | undefined
  createUser: string | undefined
  createTime: string | undefined
  sort: Array<string>
}
export interface ServiceRecordsPageQuery extends ServiceRecordsQuery, PageQuery {}

/** @desc 查询服务列表 */
export function listServiceRecords(query: ServiceRecordsPageQuery) {
  return http.get<PageRes<ServiceRecordsResp[]>>(BASE_URL, query)
}

/** @desc 查询服务详情 */
export function getServiceRecords(id: string) {
  return http.get<ServiceRecordsDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增服务 */
export function addServiceRecords(data: any) {
  return http.post(BASE_URL, data)
}

/** @desc 修改服务 */
export function updateServiceRecords(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除服务 */
export function deleteServiceRecords(id: string) {
  return http.del(BASE_URL, { ids: [id] })
}

/** @desc 下载服务impuo导入模板 */
export function downloadServiceImportTemplate() {
  return http.download(`${BASE_URL}/import/template`)
}

/** @desc 导出服务 */
export function exportServiceRecords(query: ServiceRecordsQuery) {
  return http.download(`${BASE_URL}/export`, query)
}
